﻿using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;

namespace WPF_Study
{
    public class CustomButton : Button
    {
        // 依赖属性写法
        public static readonly DependencyProperty ButtonCornerRadiusProperty = DependencyProperty.Register(
            nameof(ButtonCornerRadius), typeof(CornerRadius), typeof(CustomButton));

        // ,new PropertyMetadata(default(CornerRadius))
        // PropertyMetadata是属性默认值，如果需要就给默认值，不需要就不用写
        public CornerRadius ButtonCornerRadius
        {
            // GetValue来自于DependencyObject，因为CustomButton继承自Button，所以拥有GetValue、SetValue方法
            get { return (CornerRadius)GetValue(ButtonCornerRadiusProperty); }
            set { SetValue(ButtonCornerRadiusProperty, value); }
        }

        public static readonly DependencyProperty BackgroundHoverProperty = DependencyProperty.Register(
            nameof(BackgroundHover), typeof(Brush), typeof(CustomButton));
        // , new PropertyMetadata(default(Brush))

        public Brush BackgroundHover
        {
            get { return (Brush)GetValue(BackgroundHoverProperty); }
            set { SetValue(BackgroundHoverProperty, value); }
        }

        public static readonly DependencyProperty BackgroundPressedProperty = DependencyProperty.Register(
            nameof(BackgroundPressed), typeof(Brush), typeof(CustomButton));
        // , new PropertyMetadata(default(Brush))

        public Brush BackgroundPressed
        {
            get { return (Brush)GetValue(BackgroundPressedProperty); }
            set { SetValue(BackgroundPressedProperty, value); }
        }
    }
}